home *** CD-ROM | disk | FTP | other *** search
/ BCI NET / BCI NET Dec 94.iso / archives / applications / wp / ags-261-030.lha / gs261gs_intui.c < prev    next >
C/C++ Source or Header  |  1993-07-15  |  3KB  |  120 lines

  1. #include "gs.h"
  2. #include <stdio.h>
  3. #include <exec/types.h>
  4. #include <intuition/intuition.h>
  5. #include <intuition/cghooks.h>
  6. #include <intuition/classes.h>
  7. #include <clib/intuition_protos.h>
  8. #include <intuition/gadgetclass.h>
  9. #include <clib/utility_protos.h>
  10. #include "rkmmodel.h"
  11. #include "gxdevice.h"
  12. #include "gdevintui.h"
  13.  
  14. intui_device gs_intui_device;
  15. struct IntuitionBase *IntuitionBase;
  16. struct UtilityBase *UtilityBase;
  17. struct LayersBase *LayersBase;
  18. extern int i_close_device(gx_device *);
  19. extern struct Gadget *pg_h;
  20. extern struct Gadget *pg_v;
  21. extern Object *my_rkm_model1;
  22. extern Object *my_rkm_model2;
  23. extern int i_close_device(gx_device *);
  24.  
  25. void msg_loop(struct Window *);
  26.  
  27. void gs_intui(void)
  28. {
  29.   struct Window *w=gs_intui_device.w;
  30.   
  31.   if((IntuitionBase=(struct IntuitionBase *)\
  32.       OpenLibrary("intuition.library",LIB_REV))!=NULL)
  33.     {
  34.       if((UtilityBase=(struct UtilityBase *)\
  35.       OpenLibrary("utility.library",LIB_REV))!=NULL)
  36.     {
  37.       if((LayersBase=(struct LayersBase *)\
  38.           OpenLibrary("layers.library",LIB_REV))!=NULL)
  39.         {
  40.           ModifyIDCMP(w,IDCMP_NEWSIZE|IDCMP_IDCMPUPDATE);
  41.           /* for ever */
  42.           for(;;) msg_loop(w);
  43.         }
  44.     }
  45.     }
  46. }
  47.  
  48. void msg_loop(struct Window *w)
  49. {
  50.   struct IntuiMessage *imsg;
  51.   static LONG old_layer_xpos=0;
  52.   static LONG old_layer_ypos=0;
  53.   BOOL is_rkmmod;
  54.   int rkm_id;
  55.   ULONG val;
  56.   struct TagItem *ti;
  57.   struct TagItem *tstate;
  58.   struct RastPort *rp=gs_intui_device.rp;
  59.  
  60.   WaitPort(w->UserPort);
  61.   while((imsg=(struct IntuiMessage *)GetMsg(w->UserPort))!=NULL)
  62.     {
  63.       switch(imsg->Class)
  64.     {
  65.     case IDCMP_NEWSIZE:
  66.       SetGadgetAttrs(pg_h,w,NULL,\
  67.              PGA_Visible,w->GZZWidth/SCROLL_UNIT,
  68.              TAG_END);
  69.       SetGadgetAttrs(pg_v,w,NULL,\
  70.              PGA_Visible,w->GZZHeight/SCROLL_UNIT,\
  71.              TAG_END);
  72.       SetAttrs(my_rkm_model1,RKMMOD_Limit,(gs_intui_device.width-
  73.                            w->GZZWidth)/SCROLL_UNIT);
  74.       SetAttrs(my_rkm_model2,RKMMOD_Limit,(gs_intui_device.height-
  75.  
  76.                            w->GZZHeight)/SCROLL_UNIT);
  77.       WaitBlit();
  78.       SyncSBitMap(rp->Layer);
  79.       CopySBitMap(rp->Layer);
  80.       break;
  81.     case IDCMP_IDCMPUPDATE:
  82.       tstate=ti=(struct TagItem *)imsg->IAddress;
  83.       is_rkmmod=FALSE;
  84.       rkm_id=-1;
  85.       while((ti=NextTagItem(&tstate))!=NULL)
  86.         {
  87.           switch(ti->ti_Tag)
  88.         {
  89.         case RKMMOD_Id:
  90.           is_rkmmod=TRUE;
  91.           rkm_id=ti->ti_Data;
  92.           break;
  93.         case RKMMOD_CurrVal:
  94.           val=ti->ti_Data;
  95.           break;
  96.         }
  97.         }
  98.       if(is_rkmmod)
  99.         {
  100.           switch(rkm_id)
  101.         {
  102.         case 0:
  103.           ScrollLayer(0,rp->Layer,\
  104.                   ((LONG)val-old_layer_xpos)*SCROLL_UNIT,0);
  105.           old_layer_xpos=val;
  106.           break;
  107.         case 1:
  108.           ScrollLayer(0,rp->Layer,0,\
  109.                   ((LONG)val-old_layer_ypos)*SCROLL_UNIT);
  110.           old_layer_ypos=val;
  111.           break;
  112.         default:
  113.         }
  114.         }
  115.     }
  116.       ReplyMsg((struct Messsage *)imsg);
  117.     }
  118. }
  119.  
  120.